//
//  FindCell.m
//  MyTest
//
//  Created by zhiyou on 16-4-21.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "FindCell.h"

@implementation FindCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _imgView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:_imgView];
        
        _titleLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLab.font = [UIFont systemFontOfSize:14];
        _titleLab.numberOfLines = 2;
        [self addSubview:_titleLab];
        
        _goldLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _goldLab.font = [UIFont systemFontOfSize:12];
        _goldLab.textColor = [UIColor redColor];
        [self addSubview:_goldLab];
        
        _integralLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _integralLab.font = [UIFont systemFontOfSize:12];
        _integralLab.textColor = [UIColor redColor];
        [self addSubview:_integralLab];
        
        _trueBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _trueBtn.frame = CGRectZero;
        [_trueBtn setBackgroundColor:[UIColor redColor]];
        [_trueBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _trueBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:_trueBtn];
        
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.offset(0);
            make.height.equalTo(_imgView.mas_width);
        }];
        
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(20);
            make.top.offset(10);
            make.width.equalTo(self.mas_width).multipliedBy(.6);
        }];
        
        [_goldLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imgView.mas_right).offset(20);
            make.bottom.offset(-20);
        }];
        
        [_integralLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_goldLab.mas_right).offset(20);
            make.bottom.offset(-20);
        }];
        
        [_trueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.bottom.offset(-10);
            make.height.offset(25);
            make.width.offset(50);
        }];
    }
    return self;
}

- (void)setYouHui:(YouHui *)youHui
{
    _youHui = youHui;
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_youHui.img_path]];
    _titleLab.text = _youHui.title;
    _goldLab.text = [NSString stringWithFormat:@"%@金币",_youHui.gold];
    _integralLab.text = [NSString stringWithFormat:@"%@积分",_youHui.integral];
    if ([_youHui.status boolValue] == 1) {
        [_trueBtn setTitle:@"兑换" forState:UIControlStateNormal];
    }else {
        [_trueBtn setTitle:@"已兑完" forState:UIControlStateNormal];
    }
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
